﻿using AutoUI;
using MESPro.Controls;
using MESPro.Models;
using MESPro.Models.FunctionType;
using SqlSugar;
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Layout;

namespace RM.Controls
{
    /// <summary>
    /// 
    /// </summary>
    [RMControl("文本框(带标题)", "RMLabelTextBox.ico"), DefaultProperty("Name")]
    [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
    public partial class RMLabelTextBox : UserControl, ICustomControl, ITitleControl
    {
        private string title;
        #region Public Constructors

        public RMLabelTextBox()
        {
            InitializeComponent();
            DoubleBuffered = true;

            //this.
        }
        /// <summary>
        /// 设计时候初始化
        /// </summary>
        public void DesignerInit()
        {
            this.标题.Click += Label2_Click;
            this.标题.MouseDown += Label2_MouseDown;
            this.标题.MouseMove += Label2_MouseMove;
            this.textBox1.Click += Label2_Click;
            this.textBox1.MouseDown += Label2_MouseDown;
            this.textBox1.MouseMove += Label2_MouseMove;
        }
        private void Label2_MouseMove(object sender, MouseEventArgs e)
        {
            base.OnMouseMove(e);
        }

        private void Label2_MouseDown(object sender, MouseEventArgs e)
        {
            base.OnMouseDown(e);
        }

        private void Label2_Click(object sender, System.EventArgs e)
        {
            base.OnClick(e);
        }

        private void RMLabelTextBox_Click(object sender, System.EventArgs e)
        {
            ;
        }

        #endregion Public Constructors

        #region 属性

        /// <summary>
        /// 控件名字
        /// </summary>
        [Category("\t\t\t\t\t\t\t参数设置"), Description("名称"), DisplayName("1.名称"), Browsable(true)]
        public new string Name
        {
            get
            {
                return base.Name;
            }
            set
            {

                base.Name = value;
            }
        }
        /// <summary>
        /// 控件的标签名字
        /// </summary>
        [Category("\t\t\t\t\t\t\t参数设置"), Description("控件的标签名字"), DisplayName("2.标题"), Browsable(true)]
        public string Title
        {
            get => this.标题.Text; set
            {
                this.标题.Text = value;
                DisLanguage.SetLanguage(this.标题.Text);
            }
        }
        /// <summary>
        /// 多语言显示
        /// </summary>
        [TypeConverter(typeof(ExpandableObjectConverter))]
        [Category("\t\t\t\t\t\t\t参数设置"), Description("多语言设置"), DisplayName("5.多语言设置"), Browsable(true)]
        public DisLanguage DisLanguage { get; set; } = new()
        {
            zh_CN = "标题",
            en_US = "Title"
        };
        /// <summary>
        /// 控件Text属性
        /// </summary>
        [Category("\t\t\t\t\t\t\t参数设置"), Description("文本框的值,如果设置,将作为初始值"), DisplayName("3.数值"), Browsable(true)]
        public override string Text
        {
            get { return this.textBox1.Text; }
            set
            {
                this.textBox1.Text = value;
            }
        }

        /// <summary>
        /// 存储过程:用于后期扩展功能
        /// </summary>
        [Category("\t\t\t\t\t\t\t参数设置"),
        Description("存储过程:用于后期扩展功能"),
        DisplayName("4.存储过程"),
        TypeConverter(typeof(ExpandableObjectConverter)),
        Editor(typeof(PropertyReturnStoreProcedure), typeof(UITypeEditor))]
        [SugarColumn(IsJson = true)]
        public StoreProInfo StoredProcedure { get; set; } = new();

        [DisplayName("固定位置"), Description("固定位置"), Browsable(false)]
        public override AnchorStyles Anchor { get => base.Anchor; set => base.Anchor = value; }

        [DisplayName("定位"), Description("停靠"), Browsable(true)]
        public new Point Location { get => base.Location; set => base.Location = value; }

        [DisplayName("大小"), Description("控件的大小"), Browsable(true)]
        public new Size Size
        {
            get { return base.Size; }
            set
            {
                base.Size = value;
                this.tableLayoutPanel1.Width = (int)(value.Width * 0.8);
            }
        }

        [DisplayName("停靠位置"), Description("停靠位置"), Browsable(true)]
        public override DockStyle Dock { get => base.Dock; set => base.Dock = value; }

        [DisplayName("字体设置"), Description("字体设置"), Browsable(true)]
        public override Font Font { get => base.Font; set => base.Font = value; }

        [DisplayName("背景色"), Description("背景色"), Browsable(true)]
        public override Color BackColor { get => base.BackColor; set => base.BackColor = value; }

        [DisplayName("字体颜色"), Description("字体颜色"), Browsable(true)]
        public override Color ForeColor { get => base.ForeColor; set => base.ForeColor = value; }

        [DisplayName("边框样式"), Description("边框样式"), Browsable(true)]
        public new BorderStyle BorderStyle { get => base.BorderStyle; set => base.BorderStyle = value; }

        //.....................................
        [Browsable(false)]
        public new bool AutoScroll { get => base.AutoScroll; set => base.AutoScroll = value; }

        [Browsable(false)]
        public new Size AutoScrollMargin { get => base.AutoScrollMargin; set => base.AutoScrollMargin = value; }

        [Browsable(false)]
        public new Size AutoScrollMinSize { get => base.AutoScrollMinSize; set => base.AutoScrollMinSize = value; }

        [Browsable(false)]
        public new AutoSizeMode AutoSizeMode { get => base.AutoSizeMode; set => base.AutoSizeMode = value; }

        [Browsable(false)]
        public new AutoValidate AutoValidate { get => base.AutoValidate; set => base.AutoValidate = value; }

        [Browsable(false)]
        public new Cursor Cursor { get => base.Cursor; set => base.Cursor = value; }

        [Browsable(false)]
        public new bool Visible { get => base.Visible; set => base.Visible = value; }

        [Browsable(false)]
        public new AccessibleRole AccessibleRole { get => base.AccessibleRole; set => base.AccessibleRole = value; }

        [Browsable(false)]
        public new string AccessibleName { get => base.AccessibleName; set => base.AccessibleName = value; }

        [Browsable(false)]
        public new string AccessibleDescription { get => base.AccessibleDescription; set => base.AccessibleDescription = value; }

        [Browsable(false)]
        public new bool TabStop { get => base.TabStop; set => base.TabStop = value; }

        [Browsable(false)]
        public new int TabIndex { get => base.TabIndex; set => base.TabIndex = value; }

        [Browsable(false)]
        public new bool Enabled { get => base.Enabled; set => base.Enabled = value; }

        [Browsable(false)]
        public new bool UseWaitCursor { get => base.UseWaitCursor; set => base.UseWaitCursor = value; }

        [Browsable(false)]
        public new ImeMode ImeMode { get => base.ImeMode; set => base.ImeMode = value; }

        [Browsable(false)]
        public override System.Drawing.Image BackgroundImage { get => base.BackgroundImage; set => base.BackgroundImage = value; }

        [Browsable(false)]
        public override RightToLeft RightToLeft { get => base.RightToLeft; set => base.RightToLeft = value; }

        [Browsable(false)]
        public override LayoutEngine LayoutEngine => base.LayoutEngine;

        [Browsable(false)]
        public new bool CausesValidation { get => base.CausesValidation; set => base.CausesValidation = value; }

        [Browsable(false)]
        public override bool AutoSize { get => base.AutoSize; set => base.AutoSize = value; }

        [Browsable(false)]
        public new Padding Margin { get => base.Margin; set => base.Margin = value; }

        [Browsable(false)]
        public new Padding Padding { get => base.Padding; set => base.Padding = value; }

        [Browsable(false)]
        public new Size MaximumSize { get => base.MaximumSize; set => base.MaximumSize = value; }

        [Browsable(false)]
        public new Size MinimumSize { get => base.MinimumSize; set => base.MinimumSize = value; }

        [Browsable(false)]
        public override bool AllowDrop { get => base.AllowDrop; set => base.AllowDrop = value; }

        [Browsable(false)]
        public override Point AutoScrollOffset { get => base.AutoScrollOffset; set => base.AutoScrollOffset = value; }

        //[Browsable(false)]
        //protected override bool CanEnableIme => base.CanEnableIme;
        //[Browsable(false)]
        //public override ContextMenu ContextMenu { get => base.ContextMenu; set => base.ContextMenu = value; }

        [Browsable(false)]
        public override BindingContext BindingContext { get => base.BindingContext; set => base.BindingContext = value; }

        [Browsable(false)]
        public override ImageLayout BackgroundImageLayout { get => base.BackgroundImageLayout; set => base.BackgroundImageLayout = value; }

        [Browsable(false)]
        public override ContextMenuStrip ContextMenuStrip { get => base.ContextMenuStrip; set => base.ContextMenuStrip = value; }

        //[Browsable(false)]
        //public override Cursor Cursor { get => base.Cursor; set => base.Cursor = value; }
        [Browsable(false)]
        public new ControlBindingsCollection DataBindings { get => base.DataBindings; }

        [Browsable(false)]
        public new object Tag { get => base.Tag; set => base.Tag = value; }

        [Browsable(false)]
        protected override ImeMode ImeModeBase { get => base.ImeModeBase; set => base.ImeModeBase = value; }

        [Browsable(false)]
        protected override bool CanRaiseEvents => base.CanRaiseEvents;

        #endregion 属性

        #region Private 方法

        private void TableLayoutPanel1_MouseDown(object sender, MouseEventArgs e)
        {
            ;
        }

        #endregion Private 方法

        //public new event EventHandler Click
        //{
        //    add
        //    {
        //        base.Click += value;
        //        // textBox1.Click += value;
        //        //label2.Click += value;
        //        this.tableLayoutPanel1.Click += value;
        //    }
        //    remove
        //    {
        //        base.Click -= value;
        //        // textBox1.Click -= value;
        //        // label2.Click -= value;
        //        this.tableLayoutPanel1.Click -= value;
        //    }
        //}
        //public new event MouseEventHandler MouseDown
        //{
        //    add
        //    {
        //        base.MouseDown += value;
        //        // textBox1.Click += value;
        //        tableLayoutPanel1.MouseDown += value;
        //    }
        //    remove
        //    {
        //        base.MouseDown -= value;
        //        // textBox1.Click -= value;
        //        tableLayoutPanel1.MouseDown -= value;
        //    }
        //}
        //public new event MouseEventHandler MouseMove
        //{
        //    add
        //    {
        //        base.MouseMove += value;
        //        // textBox1.Click += value;
        //        tableLayoutPanel1.MouseMove += value;
        //    }
        //    remove
        //    {
        //        base.MouseMove -= value;
        //        // textBox1.Click -= value;
        //        tableLayoutPanel1.MouseMove -= value;
        //    }
        //}
    }
}